#include <57header.h>

pthread_mutex_t lock;
// 需要一个条件变量
pthread_cond_t cond;

void *func(void *p){

    pthread_mutex_lock(&lock);
    pthread_cond_wait(&cond, &lock);
    printf("son  fun \n");

    pthread_mutex_unlock(&lock);
    return NULL;
}
int main(int argc,char*argv[])
{
    pthread_mutex_init(&lock, NULL);
    pthread_cond_init(&cond, NULL);

    pthread_t son;
    pthread_create(&son, NULL, func, NULL);

    sleep(1);
    printf("main \n");

    pthread_cond_signal(&cond);

    pthread_join(son, NULL);
    pthread_mutex_destroy(&lock);
    pthread_cond_destroy(&cond);
    return 0;
}

